home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
rembs1.zip
/
REMBS.BAS
< prev
next >
Wrap
BASIC Source File
|
1987-03-07
|
1KB
|
53 lines
REM This program removes backspaces - chr$(8) - from text files and
REM restores text to it's corrected state for viewing and printing
REM rembs.bas - D.S. Duani 3/87
REM Microsoft QuickBASIC 2.0
defint a-z
cline$=command$
length=len(cline$)
max=(length/2)+1
dim arg$(max)
gosub argsplit 'get filenames from command line
if num+1<>2 then
print "Correct syntax is: REMBS oldfile newfile"
end
end if
open arg$(0) for input as #1
open arg$(1) for output as #2
while not eof(1)
line input #1,a$
cnt=1
b$=string$(len(a$),32)
for x=1 to len(a$)
if mid$(a$,x,1)=chr$(8) then
cnt=cnt-1:if cnt=0 then cnt=1
else
mid$(b$,cnt,1)=mid$(a$,x,1)
cnt=cnt+1
end if
next
print #2,left$(b$,cnt)
wend
close #1:close #2
end
argsplit:
true=-1: false=0
i=1:num=0:inword=true
while i <=length
ch$=mid$(cline$,i,1)
if ch$<>" " then
if not inword then inword=true
arg$(num)=arg$(num)+ch$
elseif inword then
num=num+1
inword=false
end if
i=i+1
wend
return